﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
using System.ComponentModel;

namespace BlueMarble.Genesis.Infrastructure.Background.Dynamic
{
    public class ShapeBase: UserControl, INotifyPropertyChanged
    {
        public void RenderTransformations(double Scale, double Rotation, double Opacity)
        {
            this.RenderTransformOrigin = new Point(0.5, 0.5);

            this.Opacity = Opacity;

            ScaleTransform myScaleTransform = new ScaleTransform();
            myScaleTransform.ScaleY = Scale;
            myScaleTransform.ScaleX = Scale;

            RotateTransform myRotateTransform = new RotateTransform();
            myRotateTransform.Angle = Rotation;

            // Create a TransformGroup to contain the transforms  
            // and add the transforms to it.  
            TransformGroup myTransformGroup = new TransformGroup();
            myTransformGroup.Children.Add(myScaleTransform);
            myTransformGroup.Children.Add(myRotateTransform);

            // Associate the transforms to the object  
            this.RenderTransform = myTransformGroup;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler Handler = PropertyChanged;
            if (Handler != null) Handler(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}
